package com.example.demo.service;


import com.example.demo.entity.Instrument;
import com.example.demo.entity.Notation;
import com.example.demo.mapper.NotationMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

@Service
public  class NotationImpl implements NotationService{

    @Autowired
    private NotationMapper notationMapper;





    //分页查询
    @Override
    public PageInfo<Notation> findNotationPage(Integer pageNum, Integer pageSize) {
//        if (pageNum == null) {
//            pageNum = 1; // 默认值
//        }
        PageHelper.startPage(pageNum,pageSize);
        List<Notation> lists = notationMapper.findNotationAll();
        PageInfo<Notation> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }


    //查询所有
    @Override
    public List<Notation> findNotationAll() {
        return notationMapper.findNotationAll();
    }



    //id查询
    @Override
    public Notation findNotationById(Integer notation_id) {
        return notationMapper.findNotationById(notation_id);
    }


    //插入
    @Override
    public Integer insertNotation(Notation notation) {
        return notationMapper.insertNotation(notation);
    }


    //更新
    @Override
    public Integer updateNotation(Notation notation) {
        return notationMapper.updateNotation(notation);
    }


    //删除
    @Override
    public Integer deleteNotation(Integer notation_id) {
        return notationMapper.deleteNotation(notation_id);
    }


    @Override
    public List<Notation> getHotNotations() {
        return notationMapper.findHotNotations();
    }

}
